package com.jdkreader.concurrency.queue;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.SynchronousQueue;

public class TestBlockingQueue {



    public static void test(String msg, BlockingQueue<LiftOff> queue){

        LiftOffRunner runner=new LiftOffRunner(queue);
        Thread t=new Thread(runner);
        t.start();
        for(int i = 0;i < 5;i++){
            runner.add(new LiftOff(i));
        }
        t.interrupt();
        System.out.println("finished");
    }


    public static void main(String[] args){
        test("LinkedBlockingQueue ",
                new LinkedBlockingQueue());
        test("ArrayBlockingQueue ",
                new ArrayBlockingQueue(3));
        test("SynchronousQueue ",
                new SynchronousQueue());
    }
}
